
'===============================================================================
'  Generated From - VbNet_SQL_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  **
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'MustInherit' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can Override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  Public Class YourObject
'    Inherits _YourObject
'
'  End Class
'
'===============================================================================

' Generated by MyGeneration Version # (1.3.0.3)

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Collections.Specialized

Imports MyGeneration.dOOdads

NameSpace ClassSigeco

Public MustInherit Class _si_mercaderia
	Inherits SqlClientEntity

		Public Sub New() 
			Me.QuerySource = "si_mercaderia"
			Me.MappingName = "si_mercaderia"
		End Sub

	'=================================================================
	'  Public Overrides Sub AddNew()
	'=================================================================
	'
	'=================================================================
	Public Overrides Sub AddNew()
		MyBase.AddNew()
				
	End Sub
	
	Public Overrides Sub FlushData()
		Me._whereClause = nothing
		Me._aggregateClause = nothing		
		MyBase.FlushData()
	End Sub
	
		
	'=================================================================
	'  	Public Function LoadAll() As Boolean
	'=================================================================
	'  Loads all of the records in the database, and sets the currentRow to the first row
	'=================================================================
	Public Function LoadAll() As Boolean
	
		Dim parameters As ListDictionary = Nothing
		
		
    	Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_si_mercaderiaLoadAll]", parameters)
		
	End Function

	'=================================================================
	' Public Overridable Function LoadByPrimaryKey()  As Boolean
	'=================================================================
	'  Loads a single row of via the primary key
	'=================================================================
        Public Overridable Function LoadByPrimaryKey(ByVal IdMercaderia As Integer) As Boolean

            Dim parameters As ListDictionary = New ListDictionary()
            parameters.Add(_si_mercaderia.Parameters.IdMercaderia, IdMercaderia)


            Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_si_mercaderiaLoadByPrimaryKey]", parameters)

        End Function

#Region "Parameters"
        Protected Class Parameters

            Public Shared ReadOnly Property IdMercaderia() As SqlParameter
                Get
                    Return New SqlParameter("@IdMercaderia", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property Mercaderia() As SqlParameter
                Get
                    Return New SqlParameter("@Mercaderia", SqlDbType.NVarChar, 50)
                End Get
            End Property

            Public Shared ReadOnly Property StockMinimo() As SqlParameter
                Get
                    Return New SqlParameter("@StockMinimo", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property IdMarca() As SqlParameter
                Get
                    Return New SqlParameter("@IdMarca", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property IdRubro() As SqlParameter
                Get
                    Return New SqlParameter("@IdRubro", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property Observaciones() As SqlParameter
                Get
                    Return New SqlParameter("@Observaciones", SqlDbType.NVarChar, 200)
                End Get
            End Property

            Public Shared ReadOnly Property IdImpuesto() As SqlParameter
                Get
                    Return New SqlParameter("@IdImpuesto", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property ActualizadoPor() As SqlParameter
                Get
                    Return New SqlParameter("@ActualizadoPor", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property ActualizadoFecha() As SqlParameter
                Get
                    Return New SqlParameter("@ActualizadoFecha", SqlDbType.DateTime, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodigoBarra() As SqlParameter
                Get
                    Return New SqlParameter("@CodigoBarra", SqlDbType.NVarChar, 50)
                End Get
            End Property

        End Class
#End Region

#Region "ColumnNames"
        Public Class ColumnNames

            Public Const IdMercaderia As String = "idMercaderia"
            Public Const Mercaderia As String = "mercaderia"
            Public Const StockMinimo As String = "stockMinimo"
            Public Const IdMarca As String = "idMarca"
            Public Const IdRubro As String = "idRubro"
            Public Const Observaciones As String = "observaciones"
            Public Const IdImpuesto As String = "idImpuesto"
            Public Const ActualizadoPor As String = "actualizadoPor"
            Public Const ActualizadoFecha As String = "actualizadoFecha"
            Public Const CodigoBarra As String = "codigoBarra"

            Public Shared Function ToPropertyName(ByVal columnName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(IdMercaderia) = _si_mercaderia.PropertyNames.IdMercaderia
                    ht(Mercaderia) = _si_mercaderia.PropertyNames.Mercaderia
                    ht(StockMinimo) = _si_mercaderia.PropertyNames.StockMinimo
                    ht(IdMarca) = _si_mercaderia.PropertyNames.IdMarca
                    ht(IdRubro) = _si_mercaderia.PropertyNames.IdRubro
                    ht(Observaciones) = _si_mercaderia.PropertyNames.Observaciones
                    ht(IdImpuesto) = _si_mercaderia.PropertyNames.IdImpuesto
                    ht(ActualizadoPor) = _si_mercaderia.PropertyNames.ActualizadoPor
                    ht(ActualizadoFecha) = _si_mercaderia.PropertyNames.ActualizadoFecha
                    ht(CodigoBarra) = _si_mercaderia.PropertyNames.CodigoBarra

                End If

                Return CType(ht(columnName), String)

            End Function

            Private Shared ht As Hashtable = Nothing
        End Class
#End Region

#Region "PropertyNames"
        Public Class PropertyNames

            Public Const IdMercaderia As String = "IdMercaderia"
            Public Const Mercaderia As String = "Mercaderia"
            Public Const StockMinimo As String = "StockMinimo"
            Public Const IdMarca As String = "IdMarca"
            Public Const IdRubro As String = "IdRubro"
            Public Const Observaciones As String = "Observaciones"
            Public Const IdImpuesto As String = "IdImpuesto"
            Public Const ActualizadoPor As String = "ActualizadoPor"
            Public Const ActualizadoFecha As String = "ActualizadoFecha"
            Public Const CodigoBarra As String = "CodigoBarra"

            Public Shared Function ToColumnName(ByVal propertyName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(IdMercaderia) = _si_mercaderia.ColumnNames.IdMercaderia
                    ht(Mercaderia) = _si_mercaderia.ColumnNames.Mercaderia
                    ht(StockMinimo) = _si_mercaderia.ColumnNames.StockMinimo
                    ht(IdMarca) = _si_mercaderia.ColumnNames.IdMarca
                    ht(IdRubro) = _si_mercaderia.ColumnNames.IdRubro
                    ht(Observaciones) = _si_mercaderia.ColumnNames.Observaciones
                    ht(IdImpuesto) = _si_mercaderia.ColumnNames.IdImpuesto
                    ht(ActualizadoPor) = _si_mercaderia.ColumnNames.ActualizadoPor
                    ht(ActualizadoFecha) = _si_mercaderia.ColumnNames.ActualizadoFecha
                    ht(CodigoBarra) = _si_mercaderia.ColumnNames.CodigoBarra

                End If

                Return CType(ht(propertyName), String)

            End Function

            Private Shared ht As Hashtable = Nothing

        End Class
#End Region

#Region "StringPropertyNames"
        Public Class StringPropertyNames

            Public Const IdMercaderia As String = "s_IdMercaderia"
            Public Const Mercaderia As String = "s_Mercaderia"
            Public Const StockMinimo As String = "s_StockMinimo"
            Public Const IdMarca As String = "s_IdMarca"
            Public Const IdRubro As String = "s_IdRubro"
            Public Const Observaciones As String = "s_Observaciones"
            Public Const IdImpuesto As String = "s_IdImpuesto"
            Public Const ActualizadoPor As String = "s_ActualizadoPor"
            Public Const ActualizadoFecha As String = "s_ActualizadoFecha"
            Public Const CodigoBarra As String = "s_CodigoBarra"

        End Class
#End Region

#Region "Properties"
        Public Overridable Property IdMercaderia() As Integer
            Get
                Return MyBase.Getint(ColumnNames.IdMercaderia)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.IdMercaderia, Value)
            End Set
        End Property

        Public Overridable Property Mercaderia() As String
            Get
                Return MyBase.Getstring(ColumnNames.Mercaderia)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.Mercaderia, Value)
            End Set
        End Property

        Public Overridable Property StockMinimo() As Integer
            Get
                Return MyBase.Getint(ColumnNames.StockMinimo)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.StockMinimo, Value)
            End Set
        End Property

        Public Overridable Property IdMarca() As Integer
            Get
                Return MyBase.Getint(ColumnNames.IdMarca)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.IdMarca, Value)
            End Set
        End Property

        Public Overridable Property IdRubro() As Integer
            Get
                Return MyBase.Getint(ColumnNames.IdRubro)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.IdRubro, Value)
            End Set
        End Property

        Public Overridable Property Observaciones() As String
            Get
                Return MyBase.Getstring(ColumnNames.Observaciones)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.Observaciones, Value)
            End Set
        End Property

        Public Overridable Property IdImpuesto() As Integer
            Get
                Return MyBase.Getint(ColumnNames.IdImpuesto)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.IdImpuesto, Value)
            End Set
        End Property

        Public Overridable Property ActualizadoPor() As Integer
            Get
                Return MyBase.Getint(ColumnNames.ActualizadoPor)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.ActualizadoPor, Value)
            End Set
        End Property

        Public Overridable Property ActualizadoFecha() As DateTime
            Get
                Return MyBase.GetDateTime(ColumnNames.ActualizadoFecha)
            End Get
            Set(ByVal Value As DateTime)
                MyBase.SetDateTime(ColumnNames.ActualizadoFecha, Value)
            End Set
        End Property

        Public Overridable Property CodigoBarra() As String
            Get
                Return MyBase.Getstring(ColumnNames.CodigoBarra)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.CodigoBarra, Value)
            End Set
        End Property


#End Region
	
	#Region "String Properties" 

		Public Overridable Property s_IdMercaderia As String
			Get
				If Me.IsColumnNull(ColumnNames.IdMercaderia) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.IdMercaderia)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.IdMercaderia)
				Else
					Me.IdMercaderia = MyBase.SetintAsString(ColumnNames.IdMercaderia, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Mercaderia As String
			Get
				If Me.IsColumnNull(ColumnNames.Mercaderia) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.Mercaderia)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Mercaderia)
				Else
					Me.Mercaderia = MyBase.SetstringAsString(ColumnNames.Mercaderia, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_StockMinimo As String
			Get
				If Me.IsColumnNull(ColumnNames.StockMinimo) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.StockMinimo)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.StockMinimo)
				Else
					Me.StockMinimo = MyBase.SetintAsString(ColumnNames.StockMinimo, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_IdMarca As String
			Get
				If Me.IsColumnNull(ColumnNames.IdMarca) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.IdMarca)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.IdMarca)
				Else
					Me.IdMarca = MyBase.SetintAsString(ColumnNames.IdMarca, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_IdRubro As String
			Get
				If Me.IsColumnNull(ColumnNames.IdRubro) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.IdRubro)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.IdRubro)
				Else
					Me.IdRubro = MyBase.SetintAsString(ColumnNames.IdRubro, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Observaciones As String
			Get
				If Me.IsColumnNull(ColumnNames.Observaciones) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.Observaciones)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Observaciones)
				Else
					Me.Observaciones = MyBase.SetstringAsString(ColumnNames.Observaciones, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_IdImpuesto As String
			Get
				If Me.IsColumnNull(ColumnNames.IdImpuesto) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.IdImpuesto)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.IdImpuesto)
				Else
					Me.IdImpuesto = MyBase.SetintAsString(ColumnNames.IdImpuesto, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_ActualizadoPor As String
			Get
				If Me.IsColumnNull(ColumnNames.ActualizadoPor) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.ActualizadoPor)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.ActualizadoPor)
				Else
					Me.ActualizadoPor = MyBase.SetintAsString(ColumnNames.ActualizadoPor, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_ActualizadoFecha As String
			Get
				If Me.IsColumnNull(ColumnNames.ActualizadoFecha) Then
					Return String.Empty
				Else
					Return MyBase.GetDateTimeAsString(ColumnNames.ActualizadoFecha)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.ActualizadoFecha)
				Else
					Me.ActualizadoFecha = MyBase.SetDateTimeAsString(ColumnNames.ActualizadoFecha, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodigoBarra As String
			Get
				If Me.IsColumnNull(ColumnNames.CodigoBarra) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.CodigoBarra)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodigoBarra)
				Else
					Me.CodigoBarra = MyBase.SetstringAsString(ColumnNames.CodigoBarra, Value)
				End If
			End Set
		End Property


	#End Region  	

	#Region "Where Clause"
    Public Class WhereClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffWhereParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffWhereParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "TearOff's"
		Public class TearOffWhereParameter

			Public Sub New(ByVal clause As WhereClause)
				Me._clause = clause
			End Sub
		
	
			Public ReadOnly Property IdMercaderia() As WhereParameter
				Get
					Dim where As WhereParameter = New WhereParameter(ColumnNames.IdMercaderia, Parameters.IdMercaderia)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Mercaderia() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Mercaderia, Parameters.Mercaderia)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property StockMinimo() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.StockMinimo, Parameters.StockMinimo)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property IdMarca() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.IdMarca, Parameters.IdMarca)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property IdRubro() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.IdRubro, Parameters.IdRubro)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Observaciones() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Observaciones, Parameters.Observaciones)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property IdImpuesto() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.IdImpuesto, Parameters.IdImpuesto)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property ActualizadoPor() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.ActualizadoPor, Parameters.ActualizadoPor)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property ActualizadoFecha() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.ActualizadoFecha, Parameters.ActualizadoFecha)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodigoBarra() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodigoBarra, Parameters.CodigoBarra)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property


			Private _clause as WhereClause
		End Class
		#End Region	

		Public ReadOnly Property IdMercaderia() As WhereParameter 
			Get
				If _IdMercaderia_W Is Nothing Then
					_IdMercaderia_W = TearOff.IdMercaderia
				End If
				Return _IdMercaderia_W
			End Get
		End Property

		Public ReadOnly Property Mercaderia() As WhereParameter 
			Get
				If _Mercaderia_W Is Nothing Then
					_Mercaderia_W = TearOff.Mercaderia
				End If
				Return _Mercaderia_W
			End Get
		End Property

		Public ReadOnly Property StockMinimo() As WhereParameter 
			Get
				If _StockMinimo_W Is Nothing Then
					_StockMinimo_W = TearOff.StockMinimo
				End If
				Return _StockMinimo_W
			End Get
		End Property

		Public ReadOnly Property IdMarca() As WhereParameter 
			Get
				If _IdMarca_W Is Nothing Then
					_IdMarca_W = TearOff.IdMarca
				End If
				Return _IdMarca_W
			End Get
		End Property

		Public ReadOnly Property IdRubro() As WhereParameter 
			Get
				If _IdRubro_W Is Nothing Then
					_IdRubro_W = TearOff.IdRubro
				End If
				Return _IdRubro_W
			End Get
		End Property

		Public ReadOnly Property Observaciones() As WhereParameter 
			Get
				If _Observaciones_W Is Nothing Then
					_Observaciones_W = TearOff.Observaciones
				End If
				Return _Observaciones_W
			End Get
		End Property

		Public ReadOnly Property IdImpuesto() As WhereParameter 
			Get
				If _IdImpuesto_W Is Nothing Then
					_IdImpuesto_W = TearOff.IdImpuesto
				End If
				Return _IdImpuesto_W
			End Get
		End Property

		Public ReadOnly Property ActualizadoPor() As WhereParameter 
			Get
				If _ActualizadoPor_W Is Nothing Then
					_ActualizadoPor_W = TearOff.ActualizadoPor
				End If
				Return _ActualizadoPor_W
			End Get
		End Property

		Public ReadOnly Property ActualizadoFecha() As WhereParameter 
			Get
				If _ActualizadoFecha_W Is Nothing Then
					_ActualizadoFecha_W = TearOff.ActualizadoFecha
				End If
				Return _ActualizadoFecha_W
			End Get
		End Property

		Public ReadOnly Property CodigoBarra() As WhereParameter 
			Get
				If _CodigoBarra_W Is Nothing Then
					_CodigoBarra_W = TearOff.CodigoBarra
				End If
				Return _CodigoBarra_W
			End Get
		End Property

		Private _IdMercaderia_W As WhereParameter = Nothing
		Private _Mercaderia_W As WhereParameter = Nothing
		Private _StockMinimo_W As WhereParameter = Nothing
		Private _IdMarca_W As WhereParameter = Nothing
		Private _IdRubro_W As WhereParameter = Nothing
		Private _Observaciones_W As WhereParameter = Nothing
		Private _IdImpuesto_W As WhereParameter = Nothing
		Private _ActualizadoPor_W As WhereParameter = Nothing
		Private _ActualizadoFecha_W As WhereParameter = Nothing
		Private _CodigoBarra_W As WhereParameter = Nothing

			Public Sub WhereClauseReset()

			_IdMercaderia_W = Nothing
			_Mercaderia_W = Nothing
			_StockMinimo_W = Nothing
			_IdMarca_W = Nothing
			_IdRubro_W = Nothing
			_Observaciones_W = Nothing
			_IdImpuesto_W = Nothing
			_ActualizadoPor_W = Nothing
			_ActualizadoFecha_W = Nothing
			_CodigoBarra_W = Nothing
				Me._entity.Query.FlushWhereParameters()

			End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffWhereParameter
    End Class	

	Public ReadOnly Property Where() As WhereClause
		Get
			If _whereClause Is Nothing Then
				_whereClause = New WhereClause(Me)
			End If
	
			Return _whereClause
		End Get
	End Property
	
	Private _whereClause As WhereClause = Nothing	
#End Region	

#Region "Aggregate Clause"
    Public Class AggregateClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffAggregateParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffAggregateParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "AggregateParameter TearOff's"
		Public class TearOffAggregateParameter

			Public Sub New(ByVal clause As AggregateClause)
				Me._clause = clause
			End Sub
		
	
		Public ReadOnly Property IdMercaderia() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.IdMercaderia, Parameters.IdMercaderia)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Mercaderia() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Mercaderia, Parameters.Mercaderia)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property StockMinimo() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.StockMinimo, Parameters.StockMinimo)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property IdMarca() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.IdMarca, Parameters.IdMarca)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property IdRubro() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.IdRubro, Parameters.IdRubro)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Observaciones() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Observaciones, Parameters.Observaciones)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property IdImpuesto() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.IdImpuesto, Parameters.IdImpuesto)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property ActualizadoPor() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.ActualizadoPor, Parameters.ActualizadoPor)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property ActualizadoFecha() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.ActualizadoFecha, Parameters.ActualizadoFecha)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodigoBarra() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodigoBarra, Parameters.CodigoBarra)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property


			Private _clause as AggregateClause
		End Class
		#End Region	

		Public ReadOnly Property IdMercaderia() As AggregateParameter 
			Get
				If _IdMercaderia_W Is Nothing Then
					_IdMercaderia_W = TearOff.IdMercaderia
				End If
				Return _IdMercaderia_W
			End Get
		End Property

		Public ReadOnly Property Mercaderia() As AggregateParameter 
			Get
				If _Mercaderia_W Is Nothing Then
					_Mercaderia_W = TearOff.Mercaderia
				End If
				Return _Mercaderia_W
			End Get
		End Property

		Public ReadOnly Property StockMinimo() As AggregateParameter 
			Get
				If _StockMinimo_W Is Nothing Then
					_StockMinimo_W = TearOff.StockMinimo
				End If
				Return _StockMinimo_W
			End Get
		End Property

		Public ReadOnly Property IdMarca() As AggregateParameter 
			Get
				If _IdMarca_W Is Nothing Then
					_IdMarca_W = TearOff.IdMarca
				End If
				Return _IdMarca_W
			End Get
		End Property

		Public ReadOnly Property IdRubro() As AggregateParameter 
			Get
				If _IdRubro_W Is Nothing Then
					_IdRubro_W = TearOff.IdRubro
				End If
				Return _IdRubro_W
			End Get
		End Property

		Public ReadOnly Property Observaciones() As AggregateParameter 
			Get
				If _Observaciones_W Is Nothing Then
					_Observaciones_W = TearOff.Observaciones
				End If
				Return _Observaciones_W
			End Get
		End Property

		Public ReadOnly Property IdImpuesto() As AggregateParameter 
			Get
				If _IdImpuesto_W Is Nothing Then
					_IdImpuesto_W = TearOff.IdImpuesto
				End If
				Return _IdImpuesto_W
			End Get
		End Property

		Public ReadOnly Property ActualizadoPor() As AggregateParameter 
			Get
				If _ActualizadoPor_W Is Nothing Then
					_ActualizadoPor_W = TearOff.ActualizadoPor
				End If
				Return _ActualizadoPor_W
			End Get
		End Property

		Public ReadOnly Property ActualizadoFecha() As AggregateParameter 
			Get
				If _ActualizadoFecha_W Is Nothing Then
					_ActualizadoFecha_W = TearOff.ActualizadoFecha
				End If
				Return _ActualizadoFecha_W
			End Get
		End Property

		Public ReadOnly Property CodigoBarra() As AggregateParameter 
			Get
				If _CodigoBarra_W Is Nothing Then
					_CodigoBarra_W = TearOff.CodigoBarra
				End If
				Return _CodigoBarra_W
			End Get
		End Property

		Private _IdMercaderia_W As AggregateParameter = Nothing
		Private _Mercaderia_W As AggregateParameter = Nothing
		Private _StockMinimo_W As AggregateParameter = Nothing
		Private _IdMarca_W As AggregateParameter = Nothing
		Private _IdRubro_W As AggregateParameter = Nothing
		Private _Observaciones_W As AggregateParameter = Nothing
		Private _IdImpuesto_W As AggregateParameter = Nothing
		Private _ActualizadoPor_W As AggregateParameter = Nothing
		Private _ActualizadoFecha_W As AggregateParameter = Nothing
		Private _CodigoBarra_W As AggregateParameter = Nothing

		Public Sub AggregateClauseReset()

		_IdMercaderia_W = Nothing
		_Mercaderia_W = Nothing
		_StockMinimo_W = Nothing
		_IdMarca_W = Nothing
		_IdRubro_W = Nothing
		_Observaciones_W = Nothing
		_IdImpuesto_W = Nothing
		_ActualizadoPor_W = Nothing
		_ActualizadoFecha_W = Nothing
		_CodigoBarra_W = Nothing
			Me._entity.Query.FlushAggregateParameters()

		End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffAggregateParameter
    End Class	

	Public ReadOnly Property Aggregate() As AggregateClause
		Get
			If _aggregateClause Is Nothing Then
				_aggregateClause = New AggregateClause(Me)
			End If
	
			Return _aggregateClause
		End Get
	End Property
	
	Private _aggregateClause As AggregateClause = Nothing	
#End Region	

	Protected Overrides Function GetInsertCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_si_mercaderiaInsert]" 
	    
		CreateParameters(cmd)
		
		Dim p As SqlParameter
		p = cmd.Parameters(Parameters.IdMercaderia.ParameterName)
		p.Direction = ParameterDirection.Output
    
		Return cmd 

  	End Function
	
	Protected Overrides Function GetUpdateCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_si_mercaderiaUpdate]" 
		
		CreateParameters(cmd) 
		    
		Return cmd
	
	End Function	
	
	Protected Overrides Function GetDeleteCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_si_mercaderiaDelete]" 
		
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.IdMercaderia)
		p.SourceColumn = ColumnNames.IdMercaderia
		p.SourceVersion = DataRowVersion.Current

  
		Return cmd
	
	End Function	
	
	Private Sub CreateParameters(ByVal cmd As SqlCommand)
	
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.IdMercaderia)
		p.SourceColumn = ColumnNames.IdMercaderia
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Mercaderia)
		p.SourceColumn = ColumnNames.Mercaderia
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.StockMinimo)
		p.SourceColumn = ColumnNames.StockMinimo
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.IdMarca)
		p.SourceColumn = ColumnNames.IdMarca
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.IdRubro)
		p.SourceColumn = ColumnNames.IdRubro
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Observaciones)
		p.SourceColumn = ColumnNames.Observaciones
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.IdImpuesto)
		p.SourceColumn = ColumnNames.IdImpuesto
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.ActualizadoPor)
		p.SourceColumn = ColumnNames.ActualizadoPor
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.ActualizadoFecha)
		p.SourceColumn = ColumnNames.ActualizadoFecha
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodigoBarra)
		p.SourceColumn = ColumnNames.CodigoBarra
		p.SourceVersion = DataRowVersion.Current


	End Sub	

End Class

End NameSpace

